package com.ruoyi.app.service.impl;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.app.domain.OrderProduct;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.MybatisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.app.mapper.RestockProductMapper;
import com.ruoyi.app.domain.RestockProduct;
import com.ruoyi.app.service.IRestockProductService;
import org.springframework.util.CollectionUtils;

/**
 * 进货单商品Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-12
 */
@Service
public class RestockProductServiceImpl extends ServiceImpl<RestockProductMapper, RestockProduct> implements IRestockProductService
{
    @Autowired
    private RestockProductMapper restockProductMapper;

    /**
     * 查询进货单商品
     * 
     * @param id 进货单商品主键
     * @return 进货单商品
     */
    @Override
    public RestockProduct selectRestockProductById(String id)
    {
        return baseMapper.selectById(id);
    }

    /**
     * 查询进货单商品列表
     * 
     * @param restockProduct 进货单商品
     * @return 进货单商品
     */
    @Override
    public List<RestockProduct> selectRestockProductList(RestockProduct restockProduct)
    {
        return MybatisUtils.list(baseMapper, restockProduct);
    }

    @Override
    public List<RestockProduct> listByRestockIds(Collection<String> restockIds) {

        if(CollectionUtils.isEmpty(restockIds)){
            return new ArrayList<>();
        }
        LambdaQueryWrapper<RestockProduct> lambdaQueryWrapper = new LambdaQueryWrapper<RestockProduct>();
        lambdaQueryWrapper.in(RestockProduct::getRestockId, restockIds).orderByAsc(RestockProduct::getCreateTime);
        return baseMapper.selectList(lambdaQueryWrapper);
    }
}
